load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("//pkg/testutils:buildutil/buildutil.bzl", "disallowed_imports_test")

go_library(
    name = "dev_lib",
    srcs = [
        "acceptance.go",
        "bench.go",
        "build.go",
        "builder.go",
        "cache.go",
        "compose.go",
        "dev.go",
        "doctor.go",
        "generate.go",
        "go.go",
        "lint.go",
        "main.go",
        "roachprod_stress.go",
        "test.go",
        "test_binaries.go",
        "testlogic.go",
        "ui.go",
        "util.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/cmd/dev",
    visibility = ["//visibility:private"],
    deps = [
        "//pkg/build/util",
        "//pkg/cmd/dev/io/exec",
        "//pkg/cmd/dev/io/os",
        "//pkg/util/buildutil",
        "@com_github_alessio_shellescape//:shellescape",
        "@com_github_google_shlex//:shlex",
        "@com_github_klauspost_pgzip//:pgzip",
        "@com_github_spf13_cobra//:cobra",
    ],
)

go_binary(
    name = "dev",
    embed = [":dev_lib"],
    visibility = ["//visibility:public"],
)

go_test(
    name = "dev_test",
    size = "small",
    srcs = [
        "datadriven_test.go",
        "recorderdriven_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":dev_lib"],
    deps = [
        "//pkg/build/bazel",
        "//pkg/cmd/dev/io/exec",
        "//pkg/cmd/dev/io/os",
        "//pkg/testutils/datapathutils",
        "@com_github_alessio_shellescape//:shellescape",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_google_shlex//:shlex",
        "@com_github_irfansharif_recorder//:recorder",
        "@com_github_stretchr_testify//require",
    ],
)

disallowed_imports_test(
    "dev_lib",
    allowlist = [
        "//pkg/build/util",
        "//pkg/util/buildutil",
        "//pkg/cmd/dev/io/exec",
        "//pkg/cmd/dev/io/os",
        "@com_github_alessio_shellescape//:shellescape",
        "@com_github_klauspost_compress//flate:flate",
        "@com_github_google_shlex//:shlex",
        "@com_github_klauspost_pgzip//:pgzip",
        "@com_github_irfansharif_recorder//:recorder",
        "@com_github_spf13_cobra//:cobra",
        "@com_github_spf13_pflag//:pflag",
    ],
    disallow_cdeps = True,
)
